CREATE VIEW [dbo].[vw_HIXPrescriptionReport]
AS
SELECT     dbo.DrugH.Nu_Forosh, dbo.DrugH.Resive_Name, 
                      CASE 
                        WHEN status = 0 THEN ' ' 
                        WHEN status = 1 THEN ' ' 
                        WHEN status = 2 THEN ' ' 
                      END AS StatusDrug,
                      dbo.HIX_Prescriptions.InsertDate AS RegDatePrescription, dbo.HIX_Prescriptions.ResultDate AS Giveprescription, 
                      CASE 
                        WHEN type = 1 THEN '' 
                        WHEN type = 2 THEN '' 
                      END AS Resultprescription, 
                      CASE 
                        WHEN ExceptionCode = 'ix.sender.not.corresponding.dispatcher' THEN '         '
                        WHEN ExceptionCode = 'ix.required.fields.not.found' THEN '        ' 
                        WHEN ExceptionCode = 'ix.agreement.not.found' THEN '                ' 
                        WHEN ExceptionCode = 'ix.micro.server.unreachable' THEN '        .  ' 
                        WHEN ExceptionCode = 'ix.security.pass.gen.invalid' THEN 'ј  PlainId,encryptedId,SenderId  ' 
                        WHEN ExceptionCode = 'ix.agreement.time.violated' THEN '     ' 
                        WHEN ExceptionCode = 'ix.agreement.max.request.violated' THEN '        ' 
                        WHEN ExceptionCode = 'ix.agreement.temporary.deactivate' THEN '          '
                        WHEN ExceptionCode = 'ix.timeout.occurred' THEN '    ' 
                        WHEN ExceptionCode = 'ix.receiverId.xor.receiverIds' THEN '                ' 
                        WHEN ExceptionCode = 'ix.this.action.only.one.receiverId' THEN '            ' 
                        WHEN ExceptionCode = 'ix.no.path.found.for.action' THEN '       '
                        WHEN ExceptionCode = 'ix.action.type.not.found' THEN '    ' 
                        WHEN ExceptionCode = 'ix.max.receiverIds.violated' THEN ' ϐ     ' 
                        WHEN ExceptionCode = 'ix.invalid.timeout' THEN '       '
                        WHEN ExceptionCode = 'ix.canonical.message.sender.id.null' THEN '      ' 
                        WHEN ExceptionCode = 'ix.canonical.message.receiver.id.null' THEN '      ' 
                        WHEN ExceptionCode = 'ix.canonical.message.service.null' THEN '     ' 
                        WHEN ExceptionCode = 'ix.canonical.message.action.null' THEN '     '
                        WHEN ExceptionCode = 'ix.canonical.message.version.null' THEN '      ' 
                        WHEN ExceptionCode = 'ix.canonical.message.plainId.null' THEN ' Ԙ    ' 
                        WHEN ExceptionCode = 'ix.canonical.message.encryptedId' THEN '     ' 
                        WHEN ExceptionCode = 'ix.route.path.not.found' THEN '      '
                        WHEN ExceptionCode = 'ix.endpoint.could.not.process.request' THEN '       ' 
                        WHEN ExceptionCode = 'ix.could.not.cast.sent.message' THEN '    PayloadClass' 
                        WHEN ExceptionCode = 'ix.allowed.time.gap.violated' THEN '        3   '
                        WHEN ExceptionCode = 'prescription.admissionInfo.admissionDate.is.invalid' THEN '     '
                        ELSE
                           ExceptionCode
                       END AS Messprescription, 
                       
                      dbo.HIX_Prescriptions.Id
FROM         dbo.DrugH INNER JOIN
                      dbo.HIX_Prescriptions ON dbo.HIX_Prescriptions.PrescriptionId = dbo.DrugH.Id_Havaleh


